
#include <cstdio>
#include <BTableWidget>
#include <BLayout>
#include <BButton>
#include <BWidget>
#include <BApplication>
#include <BFile>
#include <BTree>
#include <BIcon>

#include "ClassMate.h"
#include "ClassRoom.h"
#include "MainWindow.h"

void print(BTree<int>::iterator it)
{
	int level = it.level();
	while (level-- > 0)
		printf("\t");
	printf("%d\n", *it);
	for (auto sub = it.begin(); sub < it.end(); sub++)
	{
		print(sub);
	}
}

BTree<int>::iterator locate(BTree<int>& itree, const BIntArray& path)
{
	BTree<int>::iterator res = itree.find(path.first());
	if (res.empty())
		return res;
	for (int i = 1; i < path.size(); i++)
	{
		res = res.find(path[i]);
		if (res.empty())
			return res;
	}
	return res;
}

int main(int argc, char* argv[])
{
	BTree<int> itree;
	for (int i = 1; i < 5; i++)
	{
		auto it = itree.append(i);
		for (int s = 10; s < 50; s += 10)
		{
			it.append(s);
		}
	}
	BIntArray path;
	path << 2 << 20;
	BTree<int>::iterator res = locate(itree, path);
	int v = res.value();
	for (auto it = itree.begin(); it < itree.end(); it++)
	{
		print(it);
	}

	BApplication app(argc, argv);
	app.setFrequency(60);
	app.setStyleSheet("style.css");

	MainWindow widget;
	widget.setTitle("Class Room");
	widget.setIcon(new BIcon("disk-usb.jpg"));
	widget.setFrameless(true);
	widget.setName(789);
	widget.show();

	return app.execute();
}